/*
 * @param {arr} arr 数组
 * @param {object} $this 当前的调用对象this
 */
export function requiredFun(arr, $this) {
  for (let i = 0, len = arr.length; i < len; i++) {
    if (parseInt($this[arr[i][0]]) !== 0 && !$this[arr[i][0]]) {
      return {state: false, msg: arr[i][2]};
    }
    if (arr[i][1] === 'Array') {
      if ($this[arr[i][0]].length === 0) {
        return {state: false, msg: arr[i][2]};
      }
    } else if (arr[i][1] === 'number') {
      if (isNaN(parseInt($this[arr[i][0]]))) {
        return {state: false, msg: '参数' + arr[i][0] + '类型必须是' + arr[i][1]}
      }
    } else if (arr[i][1] !== '') {
      if (typeof $this[arr[i][0]] !== arr[i][1] && arr[i][1] !== 'Array') {
        return {state: false, msg: '参数' + arr[i][0] + '类型必须是' + arr[i][1]}
      }
    }
  }
  return {state: true};
};
